home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / X11 / wais / waisgate / tcp.h < prev    next >
C/C++ Source or Header  |  1995-05-09  |  14KB  |  523 lines

  1. /*                                                      System dependencies in the W3 library
  2.                                    SYSTEM DEPENDENCIES
  3.                                              
  4.    System-system differences for TCP include files and macros. This file includes for each
  5.    system the files necessary for network and file I/O.
  6.    
  7.   AUTHORS
  8.   
  9.   TBL                     Tim Berners-Lee, W3 project, CERN, <timbl@info.cern.ch>
  10.                          
  11.   EvA                     Eelco van Asperen <evas@cs.few.eur.nl>
  12.                          
  13.   MA                      Marc Andreesen NCSA
  14.                          
  15.   AT                      Aleksandar Totic <atotic@ncsa.uiuc.edu>
  16.                          
  17.   SCW                    Susan C. Weber <sweber@kyle.eitech.com>
  18.                          
  19.   HISTORY:
  20.   
  21.   22 Feb 91               Written (TBL) as part of the WWW library.
  22.                          
  23.   16 Jan 92               PC code from EvA
  24.                          
  25.   22 Apr 93               Merged diffs bits from xmosaic release
  26.                          
  27.   29 Apr 93              NT code from SCW
  28.                          
  29.  */
  30.  
  31. #ifndef TCP_H
  32. #define TCP_H
  33.  
  34. /*
  35.  
  36. Default values
  37.  
  38.    These values may be reset and altered by system-specific sections later on.  there are
  39.    also a bunch of defaults at the end .
  40.    
  41.  */
  42. /* Default values of those: */
  43. #define NETCLOSE close      /* Routine to close a TCP-IP socket         */
  44. #define NETREAD  read       /* Routine to read from a TCP-IP socket     */
  45. #define NETWRITE write      /* Routine to write to a TCP-IP socket      */
  46.  
  47. /* Unless stated otherwise, */
  48. #define SELECT                  /* Can handle >1 channel.               */
  49. #define GOT_SYSTEM              /* Can call shell with string           */
  50.  
  51. #ifdef unix
  52. #define GOT_PIPE
  53. #endif
  54. #ifdef VM
  55. #define GOT_PIPE                /* Of sorts */
  56. #endif
  57.  
  58. #ifdef DECNET
  59. typedef struct sockaddr_dn SockA;  /* See netdnet/dn.h or custom vms.h */
  60. #else /* Internet */
  61. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  62. #endif
  63.  
  64.  
  65. /*
  66.  
  67. Macintosh - Think-C
  68.  
  69.    Think-C is one development environment on the Mac.
  70.    
  71.    We recommend that you compile with 4-byte ints to be compatible with MPW C.  We used
  72.    Tom Milligan's s_socket library which was written for 4 byte int, and the MacTCP
  73.    library assumes 4-byte int.
  74.    
  75.  */
  76. #ifdef THINK_C
  77. #undef GOT_SYSTEM
  78. #define DEBUG                   /* Can't put it on the CC command line  */
  79. #define NO_UNIX_IO              /* getuid() missing                     */
  80. #define NO_GETPID               /* getpid() does not exist              */
  81. #define NO_GETWD                /* getwd() does not exist               */
  82.  
  83. #undef NETCLOSE             /* Routine to close a TCP-IP socket         */
  84. #undef NETREAD              /* Routine to read from a TCP-IP socket     */
  85. #undef NETWRITE             /* Routine to write to a TCP-IP socket      */
  86. #define NETCLOSE s_close    /* Routine to close a TCP-IP socket         */
  87. #define NETREAD  s_read     /* Routine to read from a TCP-IP socket     */
  88. #define NETWRITE s_write    /* Routine to write to a TCP-IP socket      */
  89.  
  90. #define bind s_bind         /* Funny names presumably to prevent clashes */
  91. #define connect s_connect
  92. #define accept s_accept
  93. #define listen s_listen
  94. #define socket s_socket
  95. #define getsockname s_getsockname
  96.  
  97. /* The function prototype checking is better than the include files
  98. */
  99.  
  100. extern s_close(int s);
  101. extern s_read(int s, char *buffer, int buflen);
  102. extern s_write(int s, const char *buffer, int buflen);
  103.  
  104. extern bind(int s, struct sockaddr *name, int namelen);
  105. extern accept(int s, struct sockaddr *addr, int *addrlen);
  106. extern listen(int s, int qlen);
  107. extern connect(int s, struct sockaddr *addr, int addrlen);
  108.  
  109. extern s_socket(int domain, int type, int protocol);
  110. extern s_getsockname(int s, struct sockaddr *name, int *namelen);
  111. extern struct hostent *gethostent(const char * name);
  112. extern unsigned long inet_addr(const char * name);
  113.  
  114. #endif /* THINK_C */
  115.  
  116.  
  117. /*
  118.  
  119. Macintosh - MPW
  120.  
  121.    MPW is one development environment on the Mac.
  122.    
  123.    This entry was created by Aleksandar Totic (atotic@ncsa.uiuc.edu) this file is
  124.    compatible with sockets package released by NCSA.  One major conflict is that this
  125.    library redefines write/read/etc as macros.  In some of HTML code these macros get
  126.    executed when they should not be. Such files should define NO_SOCKET_DEFS on top. This
  127.    is a temporary hack.
  128.    
  129.  */
  130. #ifdef applec                   /* MPW  */
  131. #undef GOT_SYSTEM
  132. #define DEBUG                   /* Can't put it on the CC command line */
  133. #define NO_UNIX_IO              /* getuid() missing
  134. */
  135. #define NO_GETPID               /* getpid() does not exist
  136. */
  137. #define NO_GETWD                /* getwd() does not exist
  138. */
  139.  
  140. #undef NETCLOSE             /* Routine to close a TCP-IP socket */
  141. #undef NETREAD              /* Routine to read from a TCP-IP socket */
  142. #undef NETWRITE             /* Routine to write to a TCP-IP socket */
  143. #define NETCLOSE s_close    /* Routine to close a TCP-IP socket */
  144. #define NETREAD  s_read     /* Routine to read from a TCP-IP socket */
  145. #define NETWRITE s_write    /* Routine to write to a TCP-IP socket */
  146. #define _ANSI_SOURCE
  147. #define GUI
  148. #define LINEFEED 10
  149. #define ANON_FTP_HOSTNAME
  150. #ifndef NO_SOCKET_DEFS
  151. #include <MacSockDefs.h>
  152. #endif
  153.  
  154. #include <socket.ext.h>
  155. #include <string.h>
  156.  
  157. #endif                 /* MPW */
  158.  
  159.  
  160.  
  161. #ifndef STDIO_H
  162. #include <stdio.h>
  163. #define STDIO_H
  164. #endif
  165.  
  166. /*
  167.  
  168. IBM RS600
  169.  
  170.  */
  171. /*      On the IBM RS-6000, AIX is almost Unix.
  172. **      But AIX must be defined in the makefile.
  173. */
  174. #ifdef _AIX
  175. #define AIX
  176. #endif
  177. #ifdef AIX
  178. #define unix
  179. #endif
  180.  
  181. /*    AIX 3.2
  182. **    -------
  183. */
  184.  
  185. #ifdef _IBMR2
  186. #define USE_DIRENT
  187. #endif
  188.  
  189.  
  190. /*
  191.  
  192. IBM VM-CMS, VM-XA Mainframes
  193.  
  194.    MVS is compiled as for VM. MVS has no unix-style I/O.  The command line compile options
  195.    seem to come across in lower case.
  196.    
  197.  */
  198. #ifdef mvs
  199. #define MVS
  200. #endif
  201.  
  202. #ifdef MVS
  203. #define VM
  204. #endif
  205.  
  206. #ifdef NEWLIB
  207. #pragma linkage(newlib,OS)      /* Enables recursive NEWLIB */
  208. #endif
  209.  
  210. /*      VM doesn't have a built-in predefined token, so we cheat: */
  211. #ifndef VM
  212. #include <string.h>             /* For bzero etc - not  VM */
  213. #endif
  214.  
  215. /*      Note:   All include file names must have 8 chars max (+".h")
  216. **
  217. **      Under VM, compile with "(DEF=VM,SHORT_NAMES,DEBUG)"
  218. **
  219. **      Under MVS, compile with "NOMAR DEF(MVS)" to get rid of 72 char margin
  220. **        System include files TCPIP and COMMMAC neeed line number removal(!)
  221. */
  222.  
  223. #ifdef VM                       /* or MVS -- see above. */
  224. #define NOT_ASCII               /* char type is not ASCII */
  225. #define NO_UNIX_IO              /* Unix I/O routines are not supported */
  226. #define NO_GETPID               /* getpid() does not exist */
  227. #define NO_GETWD                /* getwd() does not exist */
  228. #ifndef SHORT_NAMES
  229. #define SHORT_NAMES             /* 8 character uniqueness for globals */
  230. #endif
  231. #include <manifest.h>
  232. #include <bsdtypes.h>
  233. #include <stdefs.h>
  234. #include <socket.h>
  235. #include <in.h>
  236. #include <inet.h>
  237. #include <netdb.h>
  238. #include <errno.h>          /* independent */
  239. extern char asciitoebcdic[], ebcdictoascii[];
  240. #define TOASCII(c)   (c=='\n' ?  10  : ebcdictoascii[c])
  241. #define FROMASCII(c) (c== 10  ? '\n' : asciitoebcdic[c])
  242.  
  243. #include <bsdtime.h>
  244. #include <time.h>
  245. #include <string.h>
  246. #define INCLUDES_DONE
  247. #define TCP_INCLUDES_DONE
  248. #endif
  249.  
  250.  
  251. /*
  252.  
  253. IBM-PC running MS-DOS with SunNFS for TCP/IP
  254.  
  255.    This code thanks to Eelco van Asperen <evas@cs.few.eur.nl>
  256.    
  257.  */
  258. #ifdef PCNFS
  259. #include <sys/types.h>
  260. #include <string.h>
  261. #include <errno.h>          /* independent */
  262. #include <sys/time.h>       /* independent */
  263. #include <sys/stat.h>
  264. #include <fcntl.h>          /* In place of sys/param and sys/file */
  265. #define INCLUDES_DONE
  266. #define FD_SET(fd,pmask) (*(unsigned*)(pmask)) |=  (1<<(fd))
  267. #define FD_CLR(fd,pmask) (*(unsigned*)(pmask)) &= ~(1<<(fd))
  268. #define FD_ZERO(pmask)   (*(unsigned*)(pmask))=0
  269. #define FD_ISSET(fd,pmask) (*(unsigned*)(pmask) & (1<<(fd)))
  270. #endif  /* PCNFS */
  271.  
  272. /*
  273.  
  274. IBM-PC running Windows NT
  275.  
  276.    These parameters providede by  Susan C. Weber <sweber@kyle.eitech.com>.
  277.    
  278.  */
  279. #ifdef _WINDOWS
  280. #include "fcntl.h"                      /* For HTFile.c */
  281. #include "sys\types.h"                  /* For HTFile.c */
  282. #include "sys\stat.h"                   /* For HTFile.c */
  283.  
  284. #undef NETREAD
  285. #undef NETWRITE
  286. #undef NETCLOSE
  287. #define NETREAD(s,b,l)  ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
  288. #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
  289. #define NETCLOSE(s)     ((s)>10 ? closesocket(s) : close(s))
  290. #include <io.h>
  291. #include <string.h>
  292. #include <process.h>
  293. #include <time.h>
  294. #include <direct.h>
  295. #include <stdio.h>
  296. #include <winsock.h>
  297. typedef struct sockaddr_in SockA;  /* See netinet/in.h */
  298. #define INCLUDES_DONE
  299. #define TCP_INCLUDES_DONE
  300. #endif  /* WINDOWS */
  301.  
  302.  
  303.  
  304. /*
  305.  
  306. VAX/VMS
  307.  
  308.    Under VMS, there are many versions of TCP-IP. Define one if you do not use Digital's
  309.    UCX product:
  310.    
  311.   UCX                    DEC's "Ultrix connection" (default)
  312.                          
  313.   WIN_TCP                From Wollongong, now GEC software.
  314.                          
  315.   MULTINET               From SRI, now from TGV Inv.
  316.                          
  317.   DECNET                 Cern's TCP socket emulation over DECnet
  318.                          
  319.    The last three do not interfere with the unix i/o library, and so they need special
  320.    calls to read, write and close sockets. In these cases the socket number is a VMS
  321.    channel number, so we make the @@@ HORRIBLE @@@ assumption that a channel number will
  322.    be greater than 10 but a unix file descriptor less than 10.  It works.
  323.    
  324.  */
  325. #ifdef vms
  326. #ifdef WIN_TCP
  327. #undef NETREAD
  328. #undef NETWRITE
  329. #undef NETCLOSE
  330. #define NETREAD(s,b,l)  ((s)>10 ? netread((s),(b),(l)) : read((s),(b),(l)))
  331. #define NETWRITE(s,b,l) ((s)>10 ? netwrite((s),(b),(l)) : write((s),(b),(l)))
  332. #define NETCLOSE(s)     ((s)>10 ? netclose(s) : close(s))
  333. #endif
  334.  
  335. #ifdef MULTINET
  336. #undef NETCLOSE
  337. #undef NETREAD
  338. #undef NETWRITE
  339. #define NETREAD(s,b,l)  ((s)>10 ? socket_read((s),(b),(l)) : read((s),(b),(l)))
  340. #define NETWRITE(s,b,l) ((s)>10 ? socket_write((s),(b),(l)) : \
  341.                                 write((s),(b),(l)))
  342. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  343. #endif
  344.  
  345. #ifdef DECNET
  346. #undef SELECT  /* not supported */
  347. #undef NETREAD
  348. #undef NETWRITE
  349. #undef NETCLOSE
  350. #define NETREAD(s,b,l)  ((s)>10 ? recv((s),(b),(l),0) : read((s),(b),(l)))
  351. #define NETWRITE(s,b,l) ((s)>10 ? send((s),(b),(l),0) : write((s),(b),(l)))
  352. #define NETCLOSE(s)     ((s)>10 ? socket_close(s) : close(s))
  353. #endif /* Decnet */
  354.  
  355. /*      Certainly this works for UCX and Multinet; not tried for Wollongong
  356. */
  357. #ifdef MULTINET
  358. #include "multinet_root:[multinet.include.sys]types.h"
  359. #include "multinet_root:[multinet.include]errno.h"
  360. #include "multinet_root:[multinet.include.sys]time.h"
  361. #else
  362. #include types
  363. #include errno
  364. #include time
  365. #endif /* multinet */
  366.  
  367. #include string
  368.  
  369. #ifndef STDIO_H
  370. #include stdio
  371. #define STDIO_H
  372. #endif
  373.  
  374. #include file
  375.  
  376. #ifndef DECNET  /* Why is it used at all ? Types conflict with "types.h" */
  377. #include unixio
  378. #endif
  379.  
  380. #define INCLUDES_DONE
  381.  
  382. #ifdef MULTINET  /* Include from standard Multinet directories */
  383. #include "multinet_root:[multinet.include.sys]socket.h"
  384. #ifdef __TIME_LOADED  /* defined by sys$library:time.h */
  385. #define __TIME  /* to avoid double definitions in next file */
  386. #endif
  387. #include "multinet_root:[multinet.include.netinet]in.h"
  388. #include "multinet_root:[multinet.include.arpa]inet.h"
  389. #include "multinet_root:[multinet.include]netdb.h"
  390.  
  391. #else  /* not multinet */
  392. #ifdef DECNET
  393. #include "types.h"  /* for socket.h */
  394. #include "socket.h"
  395. #include "dn"
  396. #include "dnetdb"
  397. /* #include "vms.h" */
  398.  
  399. #else /* UCX or WIN */
  400. #include socket
  401. #include in
  402. #include inet
  403. #include netdb
  404.  
  405. #endif  /* not DECNET */
  406. #endif  /* of Multinet or other TCP includes */
  407.  
  408. #define TCP_INCLUDES_DONE
  409.  
  410. #endif  /* vms */
  411.  
  412.  
  413.  
  414. /*
  415.  
  416. SCO ODT unix version
  417.  
  418.  */
  419.  
  420. #ifdef sco
  421. #include <sys/fcntl.h>
  422. #define USE_DIRENT
  423. #endif
  424.  
  425. /*
  426.  
  427. MIPS unix
  428.  
  429.  */
  430. /* Mips hack (bsd4.3/sysV mixture...) */
  431.  
  432. #ifdef mips
  433. extern int errno;
  434. #endif
  435.  
  436.  
  437. /*
  438.  
  439. Regular BSD unix versions
  440.  
  441.    These are a default unix where not already defined specifically.
  442.    
  443.  */
  444. #ifndef INCLUDES_DONE
  445. #include <sys/types.h>
  446. /* #include <streams/streams.h>                 not ultrix */
  447. #include <string.h>
  448.  
  449. #include <errno.h>          /* independent */
  450. #include <sys/time.h>       /* independent */
  451. #include <sys/times.h>       /* independent */
  452. #include <sys/stat.h>
  453. #include <sys/param.h>
  454. #include <sys/file.h>       /* For open() etc */
  455. #define INCLUDES_DONE
  456. #endif  /* Normal includes */
  457.  
  458. /*                      Directory reading stuff - BSD or SYS V
  459. */
  460. #ifdef unix                    /* if this is to compile on a UNIX machine */
  461. #define GOT_READ_DIR 1    /* if directory reading functions are available */
  462. #ifdef USE_DIRENT             /* sys v version */
  463. #include <dirent.h>
  464. #define direct dirent
  465. #else
  466. #include <sys/dir.h>
  467. #endif
  468. #if defined(sun) && defined(__svr4__)
  469. #include <sys/fcntl.h>
  470. #include <limits.h>
  471. #endif
  472. #endif
  473.  
  474. /*
  475.  
  476. Defaults
  477.  
  478.   INCLUDE FILES FOR TCP
  479.   
  480.  */
  481. #ifndef TCP_INCLUDES_DONE
  482. #include <sys/socket.h>
  483. #include <netinet/in.h>
  484. #ifndef __hpux /* this may or may not be good -marc */
  485. #include <arpa/inet.h>      /* Must be after netinet/in.h */
  486. #endif
  487. #include <netdb.h>
  488. #endif  /* TCP includes */
  489.  
  490.  
  491. /*
  492.  
  493.   MACROS FOR MANIPULATING MASKS FOR SELECT()
  494.   
  495.  */
  496. #ifdef SELECT
  497. #ifndef FD_SET
  498. typedef unsigned int fd_set;
  499. #define FD_SET(fd,pmask) (*(pmask)) |=  (1<<(fd))
  500. #define FD_CLR(fd,pmask) (*(pmask)) &= ~(1<<(fd))
  501. #define FD_ZERO(pmask)   (*(pmask))=0
  502. #define FD_ISSET(fd,pmask) (*(pmask) & (1<<(fd)))
  503. #endif  /* FD_SET */
  504. #endif  /* SELECT */
  505.  
  506. /*
  507.  
  508.   MACROS FOR CONVERTING CHARACTERS
  509.   
  510.  */
  511. #ifndef TOASCII
  512. #define TOASCII(c) (c)
  513. #define FROMASCII(c) (c)
  514. #endif
  515.  
  516. #endif /* TCP_H */
  517.  
  518.  
  519.  
  520. /*
  521.  
  522.    end of system-specific file  */
  523.